package com.dongdongshop.controller;

import com.alibaba.fastjson.JSONObject;
import com.dk.data.R;
import com.dongdongshop.pojo.TbContentCategory;
import com.dongdongshop.service.TbcontentCateService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

//广告类型表
@Controller
@RequestMapping("tbcate")
public class TbcontentCateController {



    @DubboReference
    TbcontentCateService ttcs;



    //页面跳转
    @RequestMapping("tiao")
    public String tiao(){
        return "admin/content_category";
    }


    //查询全部
    @RequestMapping("getall")
    @ResponseBody
    public R<List<TbContentCategory>> getall(){
        List<TbContentCategory> tbcates = ttcs.getall();
        return R.ok().setData(tbcates);
    }

    //增加
    @RequestMapping("addcate")
    @ResponseBody
    public R addcate(TbContentCategory tc){
        ttcs.addcate(tc);
        return R.ok();
    }

    //修改回显
    @RequestMapping("upbyid")
    @ResponseBody
    public R<TbContentCategory> upbyid(Long id){
        TbContentCategory upbyid = ttcs.upbyid(id);
        return R.ok().setData(upbyid);
    }


    //修改
    @RequestMapping("updatecate")
    @ResponseBody
    public R updatecate(TbContentCategory tc){
        ttcs.updatecate(tc);
        return R.ok();
    }


    //删除
    @RequestMapping("deleteid")
    @ResponseBody
    public R deleteid(String ids){
        List<Long> arrs = JSONObject.parseArray(ids, Long.class);//将传过来的String类型的json转换为list集合
        ttcs.deletearr(arrs);
        return R.ok();
    }



}
